#ifndef _GORBATRAS_FBXMESH
#define _GORBATRAS_FBXMESH

#include "Gorbatras_Library.h"

namespace GC
{
	class FbxExporter;	
	class FbxBone;	
	
	class FbxMesh
	{
		
		public:		
			FbxMesh(const FbxNode* a_meshNode, fbxsdk_2014_1::FbxMesh* a_mesh,const FbxNode* a_rootNode);			

			const bool IsInitialized();	

			const FbxString GetName() const;
			const int GetID() const;
			
			
			const int GetFacesCount() const;
			const int GetVerticesPerFace() const;
			const size_t GetVerticesSize() const;
			const size_t GetVerticesIndexSize() const;
			const size_t GetNormalsSize() const;
			const size_t GetUvChannelsSize() const;
			const size_t GetBonesSize() const;			

			const VectorConstDouble GetTransform() const;
			const VectorConstDouble GetVertices() const;
			const VectorConstInt GetVerticesIndex() const;
			const VectorConstDouble GetNormals() const;

			const Vector2DConstDouble GetUVCoords() const;
			const VectorFbxBonePtr GetBones() const;

		private:		
			bool m_initialized;

			const FbxString m_name;
			const int m_id;

			const int m_verticeCount;
			const int m_facesCount;
			/// <summary>
			/// Should always be 3 because it's a triangulated mesh
			/// I'm too bad at writing WebGL code to handle not triangulated meshes :(
			/// On the bright side it's a prime number compared to scrubby 4!
			/// </summary>
			const int m_verticePerFace;

			VectorConstDouble m_transform;
			//double* m_scale;

			//The vertex values
			VectorConstDouble m_vertices;
			/// <summary>
			/// VerticeIndex is a list of what vertex is affecting what point on a face
			/// The size is faces * vertices per face
			/// </summary>
			VectorConstInt m_verticeIndex;
			//The normals
			VectorConstDouble m_normals;			
			//Amount of UV channels
			const int m_uvChannelsCount;
			//[] The channels
			//[][] The value for each channel
			Vector2DConstDouble m_uvCoordinates;

			//How many bones
			int m_boneCount;
			VectorFbxBonePtr m_bones;
			
			const bool Initialize( fbxsdk_2014_1::FbxMesh* a_mesh );
			//Sets all the mesh values, like the vertices, normals, channels, bones
			const bool SetValues(const FbxNode* a_meshNode, fbxsdk_2014_1::FbxMesh* a_mesh, const FbxNode* a_rootNode);
			const bool SetVerticeValues(fbxsdk_2014_1::FbxMesh* a_mesh);
			const bool SetFaceValues(fbxsdk_2014_1::FbxMesh* a_mesh);
			const bool SetBones(fbxsdk_2014_1::FbxMesh* a_mesh, const FbxNode* a_rootNode);			

			const FbxVector2 GetUVCoords(fbxsdk_2014_1::FbxMesh* a_mesh, const FbxGeometryElementUV* a_elementUV, const int a_faceIndex, const int a_controlPointIndex, const int a_vertexIndex);
	};
}
#endif